package com.example.home.bus;

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import com.example.home.R;
import com.example.home.bus.fragment.BusFragment;
import com.example.home.bus.fragment.MakeFragment;
import com.example.home.bus.fragment.OrderFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;


public class BusMainActivity extends AppCompatActivity {


    private BusFragment busFragment;
    private MakeFragment makeFragment;
    private OrderFragment orderFragment;

    private LinearLayout YeMian;
    private BottomNavigationView botview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bus_main);


        YeMian = findViewById(R.id.YeMian);
        botview = findViewById(R.id.botview);


        busFragment = new BusFragment();
        makeFragment = new MakeFragment();
        orderFragment = new OrderFragment();


        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian,busFragment).commit();
        botview.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.first:
                        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian, busFragment).commit();
                        break;
                    case R.id.make:
                        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian, makeFragment).commit();
                        break;
                    case R.id.order:
                        getSupportFragmentManager().beginTransaction().replace(R.id.YeMian, orderFragment).commit();
                        break;
                }
                return true;
            }
        });

    }



}